package com.xinchuang.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xinchuang.comment.R;
import com.xinchuang.domain.entity.TestMaterialsBaseInfo;
import com.xinchuang.service.TestMaterialsBaseInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 物料基础信息管理
 * @Author: thh
 * @Date: 2024/4/14 20:25
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/materialsBaseInfo")
@Api(value = "物料基础信息管理", tags = "物料基础信息管理")
public class TestMaterialsBaseInfoContoller {

    private final TestMaterialsBaseInfoService testMaterialsBaseInfoService;

    /**
     * 新增物料基础信息
     * @param list
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增物料基础信息")
    public R addMaterialsBaseInfo(@RequestBody List<TestMaterialsBaseInfo> list) {
        String r = testMaterialsBaseInfoService.addMaterialsBaseInfo(list);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 编辑物料基础信息
     * @param list
     * @return
     */
    @PostMapping("/edit")
    @ApiOperation("编辑物料基础信息")
    public R editMaterialsBaseInfo(@RequestBody List<TestMaterialsBaseInfo> list) {
        String r = testMaterialsBaseInfoService.editMaterialsBaseInfo(list);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 删除物料基础信息
     * @param jsonObject
     * @return
     */
    @PostMapping("/delete")
    @ApiOperation("删除物料基础信息")
    public R deleteMaterialsBaseInfo(@RequestBody JSONObject jsonObject) {
        String r = testMaterialsBaseInfoService.deleteMaterialsBaseInfo(jsonObject);
        return JSON.parseObject(r, R.class);
    }

    /**
     * 列表物料基础信息
     * @param jsonObject
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("列表物料基础信息")
    public R listMaterialsBaseInfo(@RequestBody JSONObject jsonObject) {
        String r = testMaterialsBaseInfoService.listMaterialsBaseInfo(jsonObject);
        return JSON.parseObject(r, R.class);
    }


}
